package com.zhilianbao.leyaogo.ui.adapter.me;

import android.content.Context;
import android.view.ViewGroup;

import com.bql.baseadapter.recycleView.QuickRcvAdapter;
import com.bql.baseadapter.recycleView.QuickRcvHolder;
import com.zhilianbao.leyaogo.R;
import com.zhilianbao.leyaogo.model.response.me.RechargeSaleCard;
import com.zhilianbao.leyaogo.utils.ImageUtils;
import com.zhilianbao.leyaogo.utils.Utils;
import com.zhilianbao.leyaogo.view.widgets.MoneyTextView;

import java.util.List;

/**
 * ClassName: RechargeSaleCardAdapter <br>
 * Description: 电商线上销售卡Adapter<br>
 * Author: Cyarie <br>
 * Created: 2017/3/8 09:52 <br>
 * Update Time：<br>
 * Update Description：<br>
 */
public class RechargeSaleCardAdapter extends QuickRcvAdapter<RechargeSaleCard> {

    public RechargeSaleCardAdapter(Context context, List<RechargeSaleCard> data) {
        super(context, data, R.layout.item_recharge_sale_card);
    }

    @Override
    protected void bindDataHelper(QuickRcvHolder holder, int position, RechargeSaleCard item) {
        ViewGroup.LayoutParams layoutParams = holder.getView(R.id.iv_card).getLayoutParams();
        layoutParams.height = layoutParams.width = (Utils.getScreenWidth() - Utils.dp2px(4) * 3) / 2;
        holder.getView(R.id.iv_card).setLayoutParams(layoutParams);
        ImageUtils.loadGoodsPic(Utils.returnUrlShow(item.getSaleCardPic()), holder.getView(R.id.iv_card));
        holder.setText(R.id.tv_card_name, item.getSaleCardUseRule());
        holder.setText(R.id.tv_card_desc, mContext.getString(R.string.deduction_percent, item.getOrderPayLimit() + ""));
        ((MoneyTextView) holder.getView(R.id.tv_card_price)).setAmount(item.getCardPrice());
    }
}
